1. /* slfpfprd.cpp by K.Tsuru */
  2. // function ID 2012 DRADIX since ver 2.182
  3. // first version made on 24 Apr 2010
  4. /***********************************************************
  5. make product
  6. p[0]^a*p[1]^b*p[2]^c...
  7. ***********************************************************/
  8. #ifndef SN_H
  9. #include "sn.h"
  10. #endif
  11. SLong PrimeFactorProduct(const SNBlock <primeFactor>& pf, int n) {
  12. SNBlock <SLong> w(4);
  13. int wc = 0, pc = 0;
  14. int pow = pf(0).power;
  15. SNBlock <SLong> wSL(n);
  16. while(pc < n) {
  17. // bind factors with the same power
  18. // ...(a^p)(b^p)(c^p)... --> ...(abc)^p...
  19. int k = 0;
  20. for(; pow == pf(pc).power; pc++) { // while the same power
  21. w.reserve(k);
  22. w[k].SetInt( pf(pc).prime );
  23. k++;
  24. }
  25. if(k > 1) { // k : number of the same power
  26. wSL[wc] = BothSideProduct(w, k, false); // sort is not necessary
  27. } else wSL[wc] = w[0]; // only one element
  28. if(pow > 1) wSL[wc] = Lpow( wSL[wc], (ulong)pow ); // wSL[wc]^pow
  29. wc++;
  30. pow = pf(pc).power; // next power
  31. }
  32. SLong Q = TournamentProduct(wSL, wc);
  33. return Q;
  34. }

slfpfprd.cpp : last modifiled at 2015/06/02 15:50:24(1,067 bytes)
created at 2017/10/07 10:26:50
The creation time of this html file is 2017/11/09 14:52:03 (Thu Nov 09 14:52:03 2017).